﻿<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
 
    <script type='text/html' template> 
        <input type='hidden' name='PID' value="{{ d.params.PID || '' }}"/>
    </script>    
    <div class='layui-form-item'>
        <label class='layui-form-label'>文章类别 <label style="color: red">*</label></label>
        <div class='layui-input-block'>
            <div class='layui-input-inline' style="width:350px">
                <script type='text/html' template>  <!--lay-done='layui.data.getSelSource(d.params,"TypeID_SelSource");'-->
                    <select name='typeidSelsource' id='TypeID_SelSource' lay-verify='required'>
                        <option value=""></option>
                        <option value='商品价格说明' {{ d.params.TypeID_SelSource == '商品价格说明' ? 'selected' : '' }}>商品价格说明</option>
                        <option value='认证帮助' {{ d.params.TypeID_SelSource == '认证帮助' ? 'selected' : '' }}>认证帮助</option>
                        <option value='系统使用说明' {{ d.params.TypeID_SelSource == '系统使用说明' ? 'selected' : '' }}>系统使用说明</option>
                        <option value='退单退货说明' {{ d.params.TypeID_SelSource == '退单退货说明' ? 'selected' : '' }}>退单退货说明</option>
                        <option value='信息公告' {{ d.params.TypeID_SelSource == '信息公告' ? 'selected' : '' }}>信息公告</option>
                    </select>
                </script>
            </div>
        </div>
    </div>   
    <div class='layui-form-item'>
        <label class='layui-form-label'>文章标题 <label style="color: red">*</label></label>
        <div class='layui-input-inline' style="width:350px">
            <script type='text/html' template>
                <input type='text' name='title' value='{{ d.params.title || '' }}' lay-verify='required' placeholder='文章标题' autocomplete='off' class='layui-input'>
            </script>
        </div>
    </div>   

    <div class='layui-form-item'>
        <label class='layui-form-label'>文章内容 <label style="color: red">*</label></label>
        <div class='layui-input-inline' style="width:350px;">
            <script type='text/html' template lay-done='layui.data.getEdit(d.params);'>
                <textarea placeholder="文章内容" name="contentEdit" id="Content_Edit" class="editor">{{ d.params.contentEdit || '' }}</textarea>
            </script>
        </div>
    </div>
    <!--<div class='layui-form-item'>
        <label class='layui-form-label'>图片路径</label>
        <div class='layui-input-inline'>
            <script type='text/html' template lay-done='layui.data.setUpload(d);'>
                <input type='text' name='Path_Upload' id='Path_Upload' value='{{ d.params.Path_Upload || '' }}' lay-verify='required' placeholder='请上传图片' autocomplete='off' class='layui-input'>
            </script>
        </div>
        <div class='layui-input-inline layui-btn-container' style='width: auto;'>
            <button type='button' class='layui-btn layui-btn-primary' id='Path_UploadBtn'>
                <i class='layui-icon'>&#xe67c;</i>上传图片
            </button>
            <button class='layui-btn layui-btn-primary' layadmin-event='Path_UploadImg'>查看图片</button>
        </div>
    </div>
     
    <div class='layui-form-item'>
        <label class='layui-form-label'>前台是否显示</label>
        <div class='layui-input-block'>
            <div class='layui-input-inline'>
                <script type='text/html' template>
                    <select name='IsShow_Sel'>
                      <option value='0' {{ d.params.IsShow_Sel == '0' ? 'selected' : '' }}>显示</option>
                      <option value='1' {{ d.params.IsShow_Sel == '1' ? 'selected' : '' }}>不显示</option>
                    </select>
                </script> 
            </div>
        </div>
    </div>-->
       
    <div class='layui-form-item'>
        <label class='layui-form-label'>排序 <label style="color: red">*</label></label>
        <div class='layui-input-inline' style="width:350px">
            <script type='text/html' template>
                <input type='text' name='order_num' value='{{ d.params.order_num || '0' }}' lay-verify='number' placeholder='排序' autocomplete='off' class='layui-input'>
            </script>
        </div>
    </div>     
    <!--<div class='layui-form-item'>
        <label class='layui-form-label'>推荐</label>
        <div class='layui-input-block'>
            <div class='layui-input-inline'>
                <script type='text/html' template>
                    <select name='Recommend_Sel'>
                      <option value='0' {{ d.params.Recommend_Sel == '0' ? 'selected' : '' }}>推荐</option>
                      <option value='1' {{ d.params.Recommend_Sel == '1' ? 'selected' : '' }}>未推荐</option>
                    </select>
                </script> 
            </div>
        </div>
    </div>
       
    <div class='layui-form-item'>
        <label class='layui-form-label'>阅读总数</label>
        <div class='layui-input-inline'>
            <script type='text/html' template>
                <input type='text' name='readCount' value='{{ d.params.readCount || '' }}' lay-verify='required|number' placeholder='阅读总数' autocomplete='off' class='layui-input'>
            </script>
        </div>
    </div>-->   
    <div class='layui-form-item'>
        <label class='layui-form-label'>备注</label>
        <div class='layui-input-inline' style="width:350px">
            <script type='text/html' template>
                <input type='text' name='rmk' value='{{ d.params.rmk || '' }}' lay-verify='' placeholder='备注' autocomplete='off' class='layui-input'>
            </script>
        </div>
    </div>   
    <!--<div class='layui-form-item'>
        <label class='layui-form-label'>其他</label>
        <div class='layui-input-inline'>
            <script type='text/html' template>
                <input type='text' name='Other' value='{{ d.params.Other || '' }}' lay-verify='required' placeholder='其他' autocomplete='off' class='layui-input'>
            </script>
        </div>
    </div>   
    <div class='layui-form-item'>
        <label class='layui-form-label'>其他</label>
        <div class='layui-input-inline'>
            <script type='text/html' template>
                <input type='text' name='Other2' value='{{ d.params.Other2 || '' }}' lay-verify='required' placeholder='其他' autocomplete='off' class='layui-input'>
            </script>
        </div>
    </div>--> 
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>

<script type="text/javascript"> 
    layui.use(['form'], function () {
        var form = layui.form;//required（必填项）phone（手机号）email（邮箱）url（网址）number（数字）date（日期）identity（身份证） 自定义值
    });
    
    layui.data.getSelSource = function (d,sourceName) { 
         layui.use(['admin','form'], function () {
                var $ = layui.$;
                var form = layui.form;
                var admin = layui.admin;
    
            if (sourceName == "TypeID_SelSource") {
                admin.req({
                    url: layui.setter.APIUrl + '/registration/articletypeMgr/customerQuery', //实际使用请改成服务端真实接口
                    type: 'post',
                    done: function (res) {
                        //$("#TypeID_SelSource").append("<option value=''>全部</option>");
                        layui.each(res.Data, function (index, eachdata) {
                            var strIsSel = '';
                            if (eachdata.PID == d.TypeID_SelSource)
                                strIsSel = "selected='selected'";
                            $("#TypeID_SelSource").append("<option value='" + eachdata.PID + "' " + strIsSel + ">" + eachdata.TypeName + "</option>");
                        });
                        form.render('select');
                    }
                }); 
            } 
        });
    }
 
     
    layui.data.setUpload = function (d) { 
        layui.use(['upload','admin'], function () {
                var $ = layui.$,
                upload = layui.upload,
                admin = layui.admin;
                var formSelects = layui.formSelects;
    
            //上传头像
            var Path_UploadSrc = $('#Path_Upload');
            upload.render({
                url: '/WebAPI/file/uploadImg?access_token=' + layui.data('layuiAdmin').access_token
              , elem: '#Path_UploadBtn'
              , accept: 'images'
              , method: 'get'
              , multiple: true
              , acceptMime: 'image/*'
              , done: function (res) {
                  if (res.ResultCode == 0) {
                      Path_UploadSrc.val(res.Data.src);
                      layer.msg('上传成功');
                  } else {
                      layer.msg(res.msg);
                  }
              }
            });

            //查看图片
            admin.events.Path_UploadImg = function (othis) {
                var src = Path_UploadSrc.val();
                layer.photos({
                    photos: {
                        "title": "查看头像", //相册标题 
                       "data": [{
                       "src": src //原图地址
                      }]
                    }
                  , shade: 0.01
                  , closeBtn: 1
                  , anim: 5
                });
            };
  
        });
    }

    layui.data.getEdit = function (d) {
        layui.use(['kindeditor', 'kindeditor_lang'],
            function () {
                var KindEditor = layui.kindeditor;
                //初始化编辑器
                var editor;
                editor = KindEditor.create('.editor', {
                    basePath: layui.setter.base + 'lib/extend/editor/',
                    width: '900px',
                    height: '370px',
                    resizeType: 1,
                    imageSizeLimit: '10MB',
                    uploadJson: '/WebAPI/file/editorUploadImg?folder=Portal_Article&access_token=' + layui.data('layuiAdmin').access_token,
                    fileManagerJson: '/WebAPI/file/ManagerFile?folder=Portal_Article&access_token=' + layui.data('layuiAdmin').access_token,
                    allowFileManager: true,
                    afterBlur: function () { this.sync(); }
                });
            });
    }
       
</script>
